import { getToken, setToken, removeToken } from '@/utils/auth'
import { queryList } from '@/api/subsys/userLog'
const userLog = {
  state: {
    token: getToken(),
    name: '',
    avatar: '',
    roles: []
  },

  mutations: {
    SET_TOKEN: (state, token) => {
      state.token = token
    },
    SET_NAME: (state, name) => {
      state.name = name
    },
    SET_AVATAR: (state, avatar) => {
      state.avatar = avatar
    },
    SET_ROLES: (state, roles) => {
      state.roles = roles
    }
  },

  actions: {
    // 查询全部/根据参数查询记录
    UserLogQueryList({ commit }, datas) {
      return new Promise((resolve, reject) => {
        queryList(datas)
          .then(response => {
            // const data = response.data
            // setToken(data.token)
            // commit('SET_TOKEN', data.token)
            resolve(response)
          })
          .catch(error => {
            reject(error)
          })
      })
    }
  }
}

export default userLog

